package com.example.demo.test.leetcode.day1210;

/**
 * 模拟
 */
public class Solution1210 {
    public static void main(String[] args) {
        System.out.println(lemonadeChange(new int[]{5,5,5,10,20}));
    }
    public static boolean lemonadeChange(int[] bills) {
        int five = 0, ten = 0;
        for (int bill : bills) {
            if (bill==5){
                five++;
            }else if (bill==10){
                if (five==0)
                    return false;
                five--;
                ten++;
            }else{
                if (five>0&&ten>0){
                    ten--;
                    five--;
                }else if (five>3){
                    five-=3;
                }else {
                    return false;
                }
            }

        }
        return true;
    }
}
